﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace YJKLevelRelated
{
	[Regeneration(RegenerationOption.Manual)]
	[Transaction(TransactionMode.Manual)]
	public class CmdLevelSet : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems)
		{
			UIApplication application = cmdData.Application;
			Transaction transaction = new Transaction(application.ActiveUIDocument.Document, this.ToString());
			try
			{
				transaction.Start();
				using (DlgLevelSet dlgLevelSet = new DlgLevelSet(cmdData, application))
				{
					dlgLevelSet.ShowDialog();
				}
				transaction.Commit();
			}
			catch
			{
				transaction.RollBack();
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
